package com.kgc.service.Impl;

import com.kgc.dao.mapper.FilesOssMapper;
import com.kgc.entity.FilesOss;
import com.kgc.service.interf.FilesOssService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

@Service
public class FilesOssServiceImpl implements FilesOssService {
    @Autowired
    private FilesOssMapper filesOssMapper;

    /**
     * 图片上传
     * @param fileName
     * @param userId
     * @param identityType
     * @return
     */
    @Override
    public int upload(String fileName, Integer userId, Integer identityType) {
        return filesOssMapper.userUploadFile(fileName,userId,identityType);
    }

    /**
     * 文件上传
     * @param filesOss
     * @return
     */
    @Override
    public int upload(FilesOss filesOss) {
        return filesOssMapper.upload(filesOss);
    }

    /**
     * 文件下载
     * @param fileId
     * @return
     */
    @Override
    public String down(Integer fileId) {
        return filesOssMapper.down(fileId);
    }

    /**
     * 获取文件下载地址
     * @param fileId
     * @return
     */
    @Override
    public String getFileUrl(Integer fileId) {
        return filesOssMapper.getFileUrl(fileId);
    }
    /**
     * 用户删除个人文件
     * @return
     */
    @Override
    public int deleteFileByUserId(FilesOss filesOss) {
        return filesOssMapper.deleteFileByUserId(filesOss);
    }

    /**
     * 管理员删除文件
     * @param fileId
     * @return
     */
    @Override
    public int deleteFile(Integer fileId) {
        return filesOssMapper.deleteFile(fileId);
    }
}
